#include "relase.h"
//#include "employee_factory.h"

// normal function
void showMenu()
{
	cout << "Welcome to Employee Management System" << endl;
    cout << "1. add employee" << endl;
    cout << "2. display employees" << endl;
    cout << "3. remove employee" << endl;
    cout << "4. modify employee" << endl;
    cout << "5. search employee" << endl;
    cout << "6. sort employees" << endl;
    cout << "7. Delete all employees" << endl;
	cout << "8. Work" << endl;
    cout << "0. Exit" << endl;
}

	void Employee_system_module()
	{

		string choice;
		employee_system system;
		system.init_system();
		
		while (1)
		{
			showMenu();
			std::cout << "Enter your choice: "<< std::endl;
			std::cin >> choice;
			if (choice == "1")
			{
				string name, department_ID,new_ID,position;
				std::cout << "Enter name: " << std::endl;
				std::cin >> name;
				std::cout << "Enter department ID: " << std::endl;
				std::cin >> department_ID;
				std::cout << "Enter ID: " << std::endl;
				std::cin >> new_ID;
				while (system.check_emp(new_ID))
				{
					std::cout << "ID already exists. Please enter a new ID: " << std::endl;
					std::cin >> new_ID;
				}
				
				std::cout << "Please enter the position of this employee, from 1 to 3, corresponding to boss, manager, and regular employee" << std::endl;
				std::cin >> position;
				if (position == "1")
				{
					//std::unique_ptr<boss>
					auto emp = std::make_unique<boss>(name, new_ID, department_ID);
					system.add_employee(std::move(emp));
					std::cout << "Employee added successfully." << std::endl;
				}
				else if (position == "2")
				{
					//std::unique_ptr<manager>
					auto emp = std::make_unique<manager>(name, new_ID, department_ID);
					system.add_employee(std::move(emp));
					std::cout << "Employee added successfully." << std::endl;
				}
				else if (position == "3")
				{
					//std::unique_ptr<employee>
					auto emp = std::make_unique<employee>(name, new_ID, department_ID);
					system.add_employee(std::move(emp));
					std::cout << "Employee added successfully." << std::endl;
				}
				else
				{
					std::cout << "Invalid position entered." << std::endl;

					
				//std::cout << "Employee added successfully." << std::endl;
			}
			}
			else if (choice == "2")
			{
				system.display_employees();
			}
			else if (choice == "3")
			{
				std::cout << "Enter ID of employee to remove: " << std::endl;
				std::string ID;
				std::cin >> ID;
				system.remove_employee(ID);
			}
			else if (choice == "4")
			{
				std::cout << "Enter ID of employee to modify: " << std::endl;
				std::string ID;
				std::cin >> ID;
				system.modify_employee(ID);
			}
			else if (choice == "5")
			{
				std::cout << "Enter ID of employee to search: " << std::endl;
				std::string ID;
				std::cin >> ID;
				system.search_employee(ID);
			}
			else if (choice == "6")
			{
				std::cout << "Enter 1 to confirm sorting, enter 0 to exit"<< std::endl;
				int choice;
				std::cin >> choice;
				if (choice == 1)
				{
					system.sort_employees();
				}
				else if (choice == 0)
				{
					std::cout << "Sorting cancelled." << std::endl;
				}
				else
				{
					std::cout << "Invalid choice entered." << std::endl;
				}
			}
			else if (choice == "7")
			{
				std::cout << "Enter 1 to confirm deleting all employees, enter 0 to exit"<< std::endl;
				int choice;
				std::cin >> choice;
				if (choice == 1)
				{
					system.delete_all_employees();
				}
				else if (choice == 0)
				{
					std::cout << "Deleting all employees cancelled." << std::endl;
				}
				else
				{
					std::cout << "Invalid choice entered." << std::endl;
				}
			}
			else if (choice == "8")
			{
				std::cout << "enter id to work" << std::endl;
				std::string ID;
				std::cin >> ID;
				system.work(ID);
			}
			else if (choice == "0")
			{
				system.exit_system();
				break;
			}
			else
			{
				std::cout << "Invalid choice entered." << std::endl;
			}

			std::cout << "press any key to continue..." << std::endl;
			//std::system("pause");
			std::cin.ignore();
			std::cin.get();
		}
		std::cout << "Exiting Employee Management System..." << std::endl;
	}